from modules.admin.models.Services import Services
from schemas.category import Create, Update


class SServices:
    @staticmethod
    def create(form: Create):
        data = Services.create(**form.dict())
        return data

    @staticmethod
    def get_all(current, size):
        data = Services.paginate(size, current)
        return data

    @staticmethod
    def get_one(Id: int):
        data = Services.find(Id)
        return data

        # 获取套餐服务

    @staticmethod
    def get_is_menu():
        data = Services.where('is_menu', 1).order_by('sort', 'desc').get(['id', 'images', 'start_price', 'original_price','name_ug','name_zh'])
        return data
    @staticmethod
    def update(form: Update,sid:str):
        data = Services.find(sid)
        print(form)
        data.update(form.model_dump())
        return data

    @staticmethod
    def delete(Id):
        data = Services.find(Id)
        data.delete()
        return data


